# coding=utf-8
from sutras import models


def update_hotwords(hotwords):
    """
    更新搜索热词
    """
    to_create = []
    for index, hotword in enumerate(hotwords):
        to_create.append(models.HotwordConfig(
            content=hotword,
            index=index))
    models.HotwordConfig.objects.all().delete()
    models.HotwordConfig.objects.bulk_create(to_create)


def get_hotwords():
    return models.HotwordConfig.objects.all().values_list("content", flat=True)
